<template>
	<view>
		<!-- 商品列表 -->
		<view class="index-body goods-list" v-if="!loading">
			<goods-list :list="goods_list"></goods-list>
		</view>

		<!-- 遮罩层 -->
		<view class="goods-model" v-if="loading">
		</view>
		<!-- <web-load v-if="loading"></web-load> -->
	</view>
</template>

<script>
	import webLoad from '../../components/unit/loading.vue';
	import goodsList from '../../components/goods/collectList.vue';
	export default {
		components:{ goodsList,webLoad  },
		data() {
			return {
				loading : true,
				page : 1,
				last_page : 1,
				goods_list : []   ,// 获得所有的商品数据
			}
		},
		onLoad() {
			this.getGoods();
		},
		onReachBottom(){
			if(this.page >= this.last_page)return this.toast('暂无更多数据~');
			this.page++;
			this.getGoods();
		},
		methods: {
			//获取商品列表
			getGoods(){
				// console.log(this.parent_classify_id);
				this.ajax('cart/collectList',{
					//  传递的参数   页数   父级分类id   子级分类id
					data:{page : this.page},
					success:(res) => {
						this.loading =false;	
						this.page = res.msg.current_page;   // 当前页
						this.last_page = res.msg.last_page;  // 最后一页
						var data = res.msg.data;    // 商品数据
						for(var i in data) {   
							this.goods_list.push(data[i]);
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.goods-model{
		position: fixed;
		top:500upx;
		left:0;
		width: 100%;
		height:100%;
		background: #fff;
		z-index:9;
	}
	
	.index-body{padding: 0 10upx;width: calc(100% - 20upx);}
</style>
